Click here to Skip to main content
13,147,812 members (35,196 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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
Updated 8-Sep-12 14:58pm
Wes Aday 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 8-Sep-12 21:20pm
Content removed, inserted verbatim into an Answer.
pasztorpisti 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 8-Sep-12 21:42pm
Sounds good to me. :)
Thanks for the tip re: some crappy compilers

1 solution

Rate this: bad
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 :)

#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;
pasztorpisti 9-Sep-12 3:30am

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170915.1 | Last Updated 8 Sep 2012
Copyright © CodeProject, 1999-2017
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