Click here to Skip to main content
11,584,040 members (45,471 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C
#include<stdio.h>
 
void main()
{
     int length, weight, c;
 
     printf("\n Plz input length: ");
     printf("\n Plz input weighth: ");
     scanf("%d", &length);
     scanf("%d", &weight);
 
     c = (length + weight)/ 2;
 
     prinf("\n perimeter: %d", c);
}

Sry im new to C just got the lession in school the yes-yesterday so here can i ask what did i wrong in the code above it keep saying error to Scanf so instead of 1 scanf i switch to 2 XD! and priftf too... ~.~ Hope to have someone help :(
Posted 8-Sep-12 14:30pm
Edited 8-Sep-12 14:58pm
v4
Comments
Wes Aday at 8-Sep-12 21:00pm
   
What is the exact error message? Does it have anything to do with the 2 different spellings of length? length and lenghth
enhzflep at 8-Sep-12 21:20pm
   
Content removed, inserted verbatim into an Answer.
pasztorpisti at 8-Sep-12 21:32pm
   
+5, This should be an answer. As an addition I would mention that the cause of a '{' error can be that some compilers want to see a newline at the end of your source file.
enhzflep at 8-Sep-12 21:42pm
   
Sounds good to me. :)
Thanks for the tip re: some crappy compilers

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Apart from the missing 't' in the 2nd last line, there's no reason for this not to compile. That said, not really sure what it is you're trying to calculate here - I guess you're just getting the hang of the language, and playing around.

Given the use of the words length and perimeter & the /2 in the final calc, I've altered it slightly so that it calculates the perimeter of a rectangle (or square)

I also separated the printf/scanf pairs so that it's easier and more intuitive to use. Enjoy Smile | :)


#include <stdio.h>

int main()
{
     int length, width, perim;
 
     printf("Plz input length: ");
     scanf("%d", &length);
 
     printf("\n Plz input width: ");
     scanf("%d", &width);
 
     perim = (length + width) * 2;
     printf("\n perimeter: %d", perim);
 
     return 0;
}
  Permalink  
Comments
pasztorpisti at 9-Sep-12 3:30am
   
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 430
1 Sergey Alexandrovich Kryukov 334
2 Richard Deeming 220
3 Dave Kreskowiak 200
4 virusstorm 194
0 OriginalGriff 1,623
1 Sergey Alexandrovich Kryukov 1,135
2 Abhinav S 701
3 Dave Kreskowiak 627
4 Suvendu Shekhar Giri 568


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 8 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100