0% found this document useful (0 votes)
5 views7 pages

C Programming Basics and Examples

The document contains 6 C programs that demonstrate basic programming concepts like printing text, using variables, performing calculations, and adding comments. Program 1 prints a simple string. Program 2 prints two strings. Program 3 prints a longer string with personal details. Program 4 calculates and prints the sum of two numbers. Program 5 calculates and prints the sum of two variables. Program 6 adds comments and calculates the sum of two integer values.

Uploaded by

Ahmad Raza
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)
5 views7 pages

C Programming Basics and Examples

The document contains 6 C programs that demonstrate basic programming concepts like printing text, using variables, performing calculations, and adding comments. Program 1 prints a simple string. Program 2 prints two strings. Program 3 prints a longer string with personal details. Program 4 calculates and prints the sum of two numbers. Program 5 calculates and prints the sum of two variables. Program 6 adds comments and calculates the sum of two integer values.

Uploaded by

Ahmad Raza
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

Computing Lab

Program No:01
Writing My First C Program
Input:
#include <stdio.h>
int main (void)
{
printf ("Programming is fun.\n");
return 0;
}
Output:
Program No:02
Input:
#include <stdio.h>
int main (void)
{
printf ("Programming is fun.\n");
printf ("And programming in C is even more fun.\n");
return 0;
}
Output:
Program No:03
Input:
#include <stdio.h>
int main (void)
{
printf ("My name is Amer Sahil. I am from Faislabad.I did my Fsc from
Multan in Muslim [Link] I am in MNS UET Multan.I am doing
Electrical Engineering here. \n");
return 0;
}
Output:
Program No:04
Displaying Variables
Input:
#include <stdio.h>
int main (void)
{
int sum;
sum = 50 + 25;
printf ("The sum of 50 and 25 is %i\n", sum);
return 0;
}
Output:
Program No:05
Displaying Multiple Values
Input:
#include <stdio.h>
int main (void)
{
int value1, value2, sum;
value1 = 150;
value2 = 125;
sum = value1 + value2;
printf ("The sum of %i and %i is %i\n", value1, value2, sum);
return 0;
}
Output:
Program No:06
Using Comments in a Program
Input:
/* This program adds two integer values
and displays the results */
#include <stdio.h>
int main (void)
{
// Declare variables
int value1, value2, sum;
// Assign values and calculate their sum
value1 =1250;
value2 = 250;
sum = value1 + value2;
}
Output:

You might also like