0% found this document useful (0 votes)
31 views

Name: Atif Latif Submitted To: Engr Sajjad Sir Assignment No: 06 Department: Telecom Batch: 16 Registration No: 17MDTLC0853 Improvement

This document contains an assignment submission for an introduction to programming course. It includes 3 programming problems and their solutions in C code. The first program prints the first 10 natural numbers using a for loop. The second program stores elements in an array and prints them. The third program creates a pyramid pattern with asterisks using nested for loops.

Uploaded by

Sufi Lines
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)
31 views

Name: Atif Latif Submitted To: Engr Sajjad Sir Assignment No: 06 Department: Telecom Batch: 16 Registration No: 17MDTLC0853 Improvement

This document contains an assignment submission for an introduction to programming course. It includes 3 programming problems and their solutions in C code. The first program prints the first 10 natural numbers using a for loop. The second program stores elements in an array and prints them. The third program creates a pyramid pattern with asterisks using nested for loops.

Uploaded by

Sufi Lines
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
You are on page 1/ 3

Introduction to Programming University of Engineering and Technology Mardan Campus

Name : Atif Latif


Submitted to : Engr Sajjad Sir
Assignment No : 06
Department : Telecom
Batch : 16
Registration No : 17MDTLC0853
Improvement

1
Introduction to Programming University of Engineering and Technology Mardan Campus

1. Write a program in c to display the first 10 natural number.


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

int main()
{
int a;
clrscr();

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


{
printf("%d\n",a);
}
getch();
return 0;
}

2. Write a program in c to store element in array and print it.


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

int main()
{
int NASIR[3],i;
clrscr();
printf("Enter 3 integer: ");
for(i = 0; i <3; i++)
{
scanf("%d",&NASIR[i]);
}
printf("You Enter These value : ");
for(i = 0; i <3; i++)
{
printf("Nasir[%d] = %d\n ",i,NASIR[i]);
}
getch();
return 0;
}

2
Introduction to Programming University of Engineering and Technology Mardan Campus

3. Write a program in c to make such pattern like pyramid with an asterisk.


*
**
***
* ***

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

int main()
{
int i,j,k;
clrscr();
for(i=1; i<=4; i++)
{
k=1;
for(j=1; j<=8; j++)
{
if(j>=6-i && j<=4+i && k)

{
printf("*");
k=0;
}
else{

printf(" ");
k=1;
}
}
printf("\n");
}

getch();
return 0;

You might also like