Programming in "C‟ | Write a „C‟ program to display cube of 1 to 10 numbers using loop.

Write a „C‟ program to display cube of 1 to 10 numbers using loop. 

(Note: Any other correct logic shall be considered).

#include<stdio.h>

#include<conio.h>

void main()

{

int i;

clrscr();

for(i=1;i<=10;i++)

printf("\n Cube of %d=%d",i,i*i*i);

getch();

--------------------------------------------------------------------

Write a program to find whether the year is leap or not.

(Note: Any other correct logic shall be considered).

#include<stdio.h>

#include<conio.h>

void main()

{

int year;

clrscr();

printf("Enter year:");

scanf("%d",&year);

if(year%4==0)

printf("\n Year is leap year");

else

printf("\n Year is not a leap year");

getch();

------------------------------------------------------------------

Write a „C‟ program to find whether the character entered is a alphabet, digit or special character.

(Note: Any other correct logic shall be considered).

#include<stdio.h>

#include<conio.h>

int main()

{

    char ch;

    printf("Enter any character: ");

    scanf("%c", &ch);

    if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))

    {

 printf("'%c' is alphabet.", ch);

    }

    else if(ch >= '0' && ch <= '9')

    {

 printf("'%c' is digit.", ch);

    }

    else

    {

 printf("'%c' is special character.", ch);

    }

    return 0;


Post a Comment

0 Comments