Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

printing on screen, some Alphabets using Turbo C

Status
Not open for further replies.

furqankaimkhani

Member level 4
Joined
Sep 10, 2010
Messages
78
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,935

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<stdio.h>
#include<conio.h>
 
void main(void)     //|_Muhammad Furqan__|
{
int j = 0;              //|____10-2-2013_____|
 clrscr();
for(int i=1;i<=7;i++)   
{
for(int n=65 ; n<72 ; n++)  // Explanation:
       printf("%c ",n);             // 'j' is for putting gap(the gap pyramid),
n=n-2;              //  'i' is for printing 7 rows and
for(j;j<i;j++)          // 'n' is for printing the Alphabets.
{                
if (j=0)                    // Problem: This "[B]if[/B]" is the stuck point.
printf("G ");           // When run, this program gets hanged
printf("\b\b  ");               // after printing one row.
}                       // apparently, without any Syntax Error.
for( n ; n>64 ; n--)        
printf("%c ",n);        
printf("\n");
}
getch();
return;
}

 
Last edited by a moderator:

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,020
Reputation
4,156
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377
if (j=0) // Problem: This "if" is the stuck point.
It is because you are using an assignment operator (=) instead of comparison (==)

- - - Updated - - -

Note that
Code:
if(j = 0)
Assigns 0 to variable j and then evaluates j.
if(0) is always false
 
Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top