WHAT IS LOOP : Loops are used to execute a piece of code several time according to the condition give to the loop. It means it execute same code multiple times so it saves code and also helps to traverse the elements of array. There are three types of loops in C language. They are : FOR loop. WHILE loop. DO WHILE loop. 1. FOR loop : Syntax : for(initialization;condition;increment/decrement) { ..... ...... ...... ...... // CODES ..... ..... ..... } Here is an example how FOR loop works : #include<stdio.h> void main() { for(int i=1;i<=10;i++) { printf("\n %d",i); } } Output : 2. WHILE loop : Syntax : while(condition) { ...... ...... ...... //code ...... ..... } Here is an example how WHILE loop works : #include<stdio.h> void main() { int i=1; while(i<=10) { printf...
Sir if i enter
ReplyDeleteRam Chandra Das
Ok sir. Thank you.
DeleteIt will still show 'R.Das' in output because only the first letter of the first name and the last name is taken to make the attribute, middle name is ignored.
DeleteCan you do it
DeleteRam Chandra Das will print as R.C.Das
#include
Deletevoid main()
{
char fname[20], mname[20], lname[20];
printf("Enter full name (first middle last): ");
scanf("%s %s %s", fname, mname, lname);
printf("Abbreviated name: ");
printf("%c. %c. %s\n", fname[0], mname[0], lname);
return 0;
}