Practical - 1 for C

Practical - 1 for C


Please, view the site in windows mode

Question:- 1 Write a C program to print "Hello World!".

    #include <stdio.h>
    #include <conio.h>

    void main ()
    {
        clrscr();
        printf("Hello World!");
        getch();
    }



Question:- 2 Write a C program to demonstrate the concept of new line character

#include <stdio.h>
#include <conio.h>

void main ()
{
    clrscr();
    printf("Hello World! \nI'm from the MSU");
    getch();
}




Question:- 3 Write a C program to demonstrate the concept of different data types

#include <stdio.h>
#include <conio.h>

void main ()
{
    // clrscr();
    int a;
    float b;
    char c;
    double d;
    printf("Enter a integer");
    scanf("%d \n" , a);
    printf("Enter a float");
    scanf("%f \n" , b);
    printf("Enter a character");
    scanf("%c \n" , c);
    printf("Enter a double");
    scanf("%f \n" , d);
    getch();
}


Question:- 4 Write a C program to demonstrate the concept of scanf function

#include <stdio.h>
#include <conio.h>

void main ()
{
    clrscr();
    int num;
    printf("Enter your number: \n");
    scanf("%d", &num);
    getch();
}



Question:- 5 Write a C program to read one number and display it.    

#include <stdio.h>
#include <conio.h>

void main ()
{
    clrscr();
    int num;
    printf("Enter your number: \n");
    scanf("%d", &num);
    printf("%d\n", num);
    getch();
}








Post a Comment

Previous Post Next Post