0% found this document useful (0 votes)
20 views4 pages

C Programming Basics: Simple Programs

This document provides a series of introductory C programming exercises, ranging from simple tasks like printing 'Hello, World!' to more complex calculations such as finding the average of three numbers and determining ASCII values. Each exercise includes the necessary code snippets and explanations for user input and output. The exercises are categorized into easy and medium levels, facilitating a gradual learning process for beginners.

Uploaded by

gopalwarke11
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

C Programming Basics: Simple Programs

This document provides a series of introductory C programming exercises, ranging from simple tasks like printing 'Hello, World!' to more complex calculations such as finding the average of three numbers and determining ASCII values. Each exercise includes the necessary code snippets and explanations for user input and output. The exercises are categorized into easy and medium levels, facilitating a gradual learning process for beginners.

Uploaded by

gopalwarke11
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

UNIT 1 – Introduction to C Programming

􀀀 Easy
1. Write a program to print “Hello, World!”.
#include<stdio.h>

int main(){

printf("Hello, World!");

return 0;

2. Write a program to add two integers entered by the user.


#include<stdio.h>

int main(){

int n1,n2,sum;

printf("Enter No by Space:");

scanf("%d %d",&n1,&n2);

sum=n1+n2;

printf("Sum of Two Number is %d.",sum);

return 0;

3. Write a program to calculate the area of a circle.


#include<stdio.h>

int main(){

float pi,r,area;

pi=3.14;

printf("Enter radius: ");

scanf("%f",&r);
area=pi*(r*r);

printf("The area of the circle is %.2f.",area);

return 0;

4. Write a program to convert temperature from Celsius to


Fahrenheit.
#include<stdio.h>

int main(){

float celsius,fahrenheit;

printf("Enter the temperture in celsius: ");

scanf("%f",&celsius);

fahrenheit=(celsius * 9/5) + 32;

printf("Fahrenheit= %.2f",fahrenheit);

return 0;

5. Write a program to calculate the simple interest.


#include<stdio.h>

int main(){

int si,p,r,t;

printf("Enter principal:");

scanf("%d",&p);

printf("Enter rate of intrest:");

scanf("%d",&r);

printf("Enter time:");

scanf("%d",&t);

si=(p*r*t)/100;

printf("Simple intrest:%d",si);
return 0;

􀀀 Medium
6. Write a program to compute the average of three numbers.
#include<stdio.h>

int main(){

int avg,n1,n2,n3;

printf("Enter Three No With Space: ");

scanf("%d %d %d",&n1,&n2,&n3);

avg=(n1+n2+n3)/3;

printf("Average of Three No: %d",avg);

return 0;

7. Write a program to find the square and cube of a number.


#include<stdio.h>

int main(){

int n;

printf("Enter No: ");

scanf("%d",&n);

printf("Square of the no: %d\n",n*n);

printf("Cube of the no: %d",n*n*n);


return 0;

8. Write a program to find ASCII value of a character.


#include<stdio.h>

int main(){

char ch;

printf("Enter the charater: ");

scanf("%c",&ch);

printf("ASCII Value : %d",ch);

return 0;

You might also like