473,569 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make program to square the numbers from 1 to 20

5 New Member
hello,...i want to make program to square the numbers from 1 to 20. i have written this program, it's running but not giving the required answer.i think it is giving a garbage value...please tell me where is the issue....I'm very basic programmer studying C++...hope you'll response soon

Expand|Select|Wrap|Line Numbers
  1. void main(void)
  2. {int a;
  3.   int  b;
  4. b=a*a;
  5. for (a=1; a<21; a++)
  6. {printf("%d",b);
  7. printf("the square is%d=b");
  8. }
  9. getche();}
Oct 21 '12 #1
2 3702
weaknessforcats
9,208 Recognized Expert Moderator Expert
Your calculation of the square is outside your loop.
Oct 21 '12 #2
sgayathri2412
8 New Member
Expand|Select|Wrap|Line Numbers
  1. printf("the square is%d=b");
//statement wrong.It should be

Expand|Select|Wrap|Line Numbers
  1. printf("the square is %d",b);
//if not garbage value only returns.
Oct 25 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1616
by: Lau Alvin | last post by:
HI all , I want to make a button which have a server side OnClick event in .cs to update the DB. But I want it to have a client side onclick event to run a javascript popup too. And the javascript will be run only in some conditions determine by the input of some webcontrols. Finally the server side event will depend on the chioce of user...
5
11096
by: scorpion53061 | last post by:
Is there a way that anyone knows to force a vb.net program to shut down and then restart itself?
0
1625
by: goosen_cug | last post by:
hello.everyone,i am an chinese.i study in China University of Geosiences,as i like english and C++(program) very much,i also want to make friends with a foriger to improve my english and the ability of program.so i hope there are some person who want to make friends with me,if you want to email me,please sent emails to goosen108@gmail. I...
6
1606
by: Howard | last post by:
Just curious What is the largest program you have written in terms of source code length and complexity? Howard
1
3157
by: Anh Khuong | last post by:
Hi all, In some cases I click button to open dialog using ShowDialog(this) method, it make program freeze. Can you show me which cases this method cause problem above? Here are stack dump debug: 00000000() system.windows.forms.dll!System.Windows.Forms.Control.SetParentHandle(int value = 594188) + 0x280 bytes
3
1835
by: dolphin | last post by:
Is there someone have written some programs about RSA-1024.What about Montgomery?What it is?What is the result of it?sorry for my poor english.
2
2697
by: alberto | last post by:
I am Very new to .net but have experience with C++ and other languages. Can somebody point me to a "hello world" database program? Create one table (managed to do that with an .mdf database file and designed a simple table) and fill it up through a datagrid from scratch. I do not want to download the northwind database and the dvds program...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.