Monday, October 19, 2015

Inputting Integers, characters, and strings

#include <stdio.h>
#include <string.h>

void main()
{
    int a, b;
    float c, d;
    double e, f;
    char g,h;

    char hello[10], cousin[10];

    a=10; b=12; c=10; d=12; e=10; f=12;

    g='H'; h='C';

     strcpy(hello, "Howzit");printf("\na=%d, b=%d, c=%f, d=%f \n", a,b,c,d);

    strcpy(cousin, "Cuz");

    printf("\na=%d, b=%d, c=%f, d=%f \n", a,b,c,d);
    printf("\ne=%f, f=%f\n",e,f);
   
    printf("\ng=%c, h=%c\n\n", g,h);

    printf("\nHello=%s, Cousin=%s\n\n",hello,cousin);

    printf("a= ");
    scanf("%d",&a);

    printf("\nb= ");
    scanf("%d", &b);

    printf("\n\n");printf("\na=%d, b=%d, c=%f, d=%f \n", a,b,c,d);

    printf("\na=%d \tb=%d \tc=%f \td=%f \n", a,b,c,d);

    printf("Input String hello:  ");
    scanf("%s",&hello);

    printf("Input String cousin:  ");
    scanf("%s", &cousin);


/*    scanf("Input Hello String=%s and Input Cousin String=%s", hello, cousin); */

/*    scanf("Input Hello String=%s and Input Cousin String=%s", hello, cousin); */
    printf("\n\nHello = %s \n",hello);

    printf("\nCousin = %s \n",cousin);

    printf("\n\n%s %s\n\n",hello,cousin);

    puts(hello);
    puts(cousin);


}

No comments:

Post a Comment