-->

WAP to initialize some characters and display them.

the code looks like
------------------------------------------------------
//program to initialize some characters and to print them
#include <stdio.h>
#include<conio.h>

void main()
{
    char name[10]={'r','m','a','n'};//initialization of characters
    int i;
    for(i=0;name[i]!='\0';i++)//loop execution untill null character
    {
        printf("%c",name[i]);//printing the value
    }
   

    getch();
}

---------------------------
second method
----------------------------------------------
//program to initialize some characters and to print them
#include <stdio.h>
#include<conio.h>

void main()
{
    char name[10]={'r','m','a','n'};//initialization of characters
 
        printf("%s",name);//printing the value
   
   

    getch();
}










-------------------------------
in codeblocks:-
-------------------------------
#include <stdio.h>

int main()
{
    char name[10]={'r','m','a','n'};
    int i;
    for(i=0;name[i]!='\0';i++)
    {
        printf("%c",name[i]);
    }
   

    return 0;
}


No comments:

Post a Comment