Q. If sum of two integer is 14 and if one of them is 8 then find other integer. Ans: Well, this is very simple. Simply, one integer is 8 and sum of two integers is 14. So, we need to subtract the number 8 from their sum of 14 to get the second number. So, the second number is: 14 - 8 = 6 C-Program of this task Code---> #include<stdio.h> int main () { int num1 = 8 , num2 , sum = 14 ; num2 = sum - num1 ; printf ( "The second number is: %d" , num2 ); return 0 ; }
In this C program we will copy the contents of a string into another without strcpy()fuction. The String will be given by the User.
Learn about different string functions and their use: Different String Functions
input:
The String.output:
The input string and the copied string will be printed on the screen.
CODE---->
#include<stdio.h>
#include<string.h>
int main()
{
int n=0;
char source_str[100],target_str[100];
printf("Please, Enter a string: ");
gets(source_str);
while(source_str[n]!='\0')
{
target_str[n]=source_str[n];
n++;
}
target_str[n]='\0';
printf("\nThe source string is: ");
puts(source_str);
printf("\nThe copied string is: ");
puts(target_str);
return 0;
}
Download the C-Program file of this Program.
RESULT :
Please, Enter a string: Please, Follow Us too... ProgramJoy Loves You. The source string is: Please, Follow Us too... ProgramJoy Loves You. The copied string is: Please, Follow Us too... ProgramJoy Loves You. -------------------------------- Process exited after 32.89 seconds with return value 0 Press any key to continue . . .
Images for better understanding :
Using Function :
#include<stdio.h>
#include<string.h>
void STRCPY(char *t,char *s)
{
while(*s!='\0')
{
*t=*s;
s++;
t++;
}
*t='\0';
}
int main()
{
char source_str[100],target_str[100];
printf("Please, Enter a string: ");
gets(source_str);
STRCPY(target_str,source_str);
printf("\nThe source string is: ");
puts(source_str);
printf("\nThe copied string is: ");
puts(target_str);
return 0;
}
Download the C-Program file of this Program.
RESULT :
Please, Enter a string: Please, SUBSCRIBE to ProgramJoy The source string is: Please, SUBSCRIBE to ProgramJoy The copied string is: Please, SUBSCRIBE to ProgramJoy -------------------------------- Process exited after 30.45 seconds with return value 0 Press any key to continue . . .
Images for better understanding :
Hard Rock Casino & Resort in Scottsdale, AZ - Dr.MCD
ReplyDeleteA 양산 출장마사지 place to experience the Hard 순천 출장샵 Rock Experience. 청주 출장안마 Experience the thrills and excitement of 구리 출장안마 Rockin' Rockin' Rockin' 밀양 출장샵 Rockin' Casino!